package algorithm;

import bean.Credit_parameter;
import java.util.HashMap;
import java.util.Map;
public class Basketball_credit {

	
	//参数顺序（得分，抢断，篮板，助攻，比赛等级，过往成绩）
	public Map<String,Double> Get_basketball_score(int basketball_point,int basketball_steal,int basketball_rebound,int basketball_assist,int basketball_level,double basketball_record){
		
		//篮球得分规则
		if(basketball_point <= 0){
			basketball_point = 0;
		}
		else if(basketball_point > 0 && basketball_point <= 10){    
			basketball_point = 4 * basketball_point; 
		}
		else if(basketball_point > 10 && basketball_point <= 20){
			basketball_point = 2 * (basketball_point - 10) + 40;
		}
		else if(basketball_point > 20 && basketball_point <= 25){
			basketball_point = 4 * (basketball_point - 20) + 60;
		}
		else{
			basketball_point = (int) (80 + 20 * basketball_point / (basketball_point + 6.25));
		}
		
		if(basketball_steal <= 3){    //篮球抢断规则
			basketball_steal = 0; 
		}
		else if(basketball_steal > 3 && basketball_steal <= 5){
			basketball_steal = 10 *(basketball_steal - 3);
		}
		else if(basketball_steal > 5 && basketball_steal <= 9) {
			basketball_steal = 20 * (basketball_steal - 5) + 20;
		}
		else {
			basketball_steal = 100;
		}
		
		if(basketball_rebound <= 0){  //篮球篮板规则
			basketball_rebound = 0; 
		}
		else if(basketball_rebound > 0 && basketball_rebound <= 10){
			basketball_rebound = 10 * basketball_rebound;
		}
		else{
			basketball_rebound = 100;
		}
		
		if(basketball_assist <= 0){  //篮球助攻规则
			basketball_assist = 0; 
		}
		else if(basketball_assist > 0 && basketball_assist <= 10){
			basketball_assist = 10 * basketball_assist;
		}
		else{
			basketball_assist = 100;
		}
		
		
		//篮球等级规则
		if(basketball_level <= Credit_parameter.getMatch_level_1() ){
			basketball_level = Credit_parameter.getMatch_level_1();
		}
		else if(basketball_level >= Credit_parameter.getMatch_level_2() && basketball_level <= Credit_parameter.getMatch_level_1()){
			basketball_level = Credit_parameter.getMatch_level_2();
		}
		else if(basketball_level >= Credit_parameter.getMatch_level_3() && basketball_level <= Credit_parameter.getMatch_level_4()){
			basketball_level = Credit_parameter.getMatch_level_3();
		}
		else if(basketball_level >= Credit_parameter.getMatch_level_4()){
			basketball_level = Credit_parameter.getMatch_level_4();
		}
		
		//篮球总积分计算公式
		double basketball_Credit = (1 - Credit_parameter.getProfession_basketball_assist_weight() - 
				Credit_parameter.getProfession_basketball_ponit_weight() - 
				Credit_parameter.getProfession_basketball_rebound_weight() - 
				Credit_parameter.getProfession_basketball_steal_weight()) * basketball_level +
				Credit_parameter.getProfession_basketball_ponit_weight() * basketball_point +
				Credit_parameter.getProfession_basketball_assist_weight() * basketball_assist +
				Credit_parameter.getProfession_basketball_rebound_weight() * basketball_rebound +
				Credit_parameter.getProfession_basketball_steal_weight() * basketball_steal ;
		double basketball_Record = basketball_Credit * (1 - Credit_parameter.getProfession_basketball_record_weight()) + Credit_parameter.getProfession_basketball_record_weight() * basketball_record;
		Map<String,Double> map =new HashMap<String,Double>();
		map.put("basketball_credit",basketball_Credit * Credit_parameter.getProfession_basketball_result_weight());
		map.put("basketball_record", basketball_Record);
		
		//判断积分是否变化
		double flag;
		if(basketball_Credit == 0){     //flag标志，0表示积分无变化
			flag = 0;
		}
		else{
			flag = 1;
		}
		map.put("flag", flag);          //flag标志，1表示积分无变化
		return map;
	}

}
